//
// Created by 123 on 2024/12/30.
//
#include "iostream"
using namespace std;

int* func(){
    int a = 10;
    //不要返回栈区引用
    return &a;
}
int* func2(){
    int* a = new int(10);
    //可以返回堆区引用
    return a;
}

int main040(){
//    int* p = func();
//    cout << *p << endl;
//    cout << *p << endl;
//    cout << *p << endl;
//    cout << *p << endl;
    int* ptr = func2();
    cout << *ptr << endl;
    cout << *ptr << endl;

    return 0;
}